package View;

import Client.Client;
import Shared.Server;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.DefaultListModel;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

/**
 *
 * @author CCD gruppe 2
 */
public class ActivityListPanel extends JPanel {

    private javax.swing.JLabel activityHeader;
    private javax.swing.JList activityJList;
    private javax.swing.JButton deleteActivityButton;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JButton newActivityButton;
    DefaultListModel activityListModel;

    public ActivityListPanel() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     */
    public void initComponents() {
        activityHeader = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        activityJList = new javax.swing.JList();
        newActivityButton = new javax.swing.JButton();
        deleteActivityButton = new javax.swing.JButton();
        activityListModel = new DefaultListModel();

        activityHeader.setFont(new java.awt.Font("Lucida Grande", 1, 13));
        activityHeader.setText("Aktiviteter");

        jScrollPane2.setViewportView(activityJList);

        newActivityButton.setText("Ny aktivitet");


        deleteActivityButton.setText("Slett");
        activityJList.setModel(activityListModel);


        org.jdesktop.layout.GroupLayout activityListPanelLayout = new org.jdesktop.layout.GroupLayout(this);
        this.setLayout(activityListPanelLayout);
        activityListPanelLayout.setHorizontalGroup(
            activityListPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, activityListPanelLayout.createSequentialGroup()
                .add(activityListPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, activityListPanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .add(activityListPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(org.jdesktop.layout.GroupLayout.CENTER, activityHeader)
                            .add(org.jdesktop.layout.GroupLayout.CENTER, jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 183, Short.MAX_VALUE)))
                    .add(org.jdesktop.layout.GroupLayout.LEADING, activityListPanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .add(activityListPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, deleteActivityButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 186, Short.MAX_VALUE)
                            .add(newActivityButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 186, Short.MAX_VALUE))))
                .addContainerGap())
        );
        activityListPanelLayout.setVerticalGroup(
            activityListPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(activityListPanelLayout.createSequentialGroup()
                .add(activityHeader)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 409, Short.MAX_VALUE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(newActivityButton)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(deleteActivityButton)
                .add(26, 26, 26))
        );



    }

    /**
     * A method that adds an activity to the list
     * @param activityName
     */
    public void addActivity(String activityName) {

        activityListModel.addElement(activityName);
        activityJList.setSelectedIndex(activityListModel.size() + 1);

    }

    /*
     * Getters and setters
     */
    public JLabel getActivityHeader() {
        return activityHeader;
    }

    public JList getActivityJList() {
        return activityJList;
    }

    public DefaultListModel getActivityListModel() {
        return activityListModel;
    }

    public JButton getDeleteActivityButton() {
        return deleteActivityButton;
    }

    public JScrollPane getjScrollPane2() {
        return jScrollPane2;
    }

    public JButton getNewActivityButton() {
        return newActivityButton;
    }
}
